class WorkTime < ApplicationRecord
  belongs_to :restaurant

  has_many :time_rules

  scope :filter_status, ->(status) { where status: status if status.present? }
  scope :filter_open, -> { filter_status 'open' }
  scope :filter_closed, -> { filter_status 'closed' }

  def validate_rule?(params)
    time_rules.all? { |rule| rule.validate_value?(params) }
  end
end
